home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-12-16 | 26.9 KB | 934 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: DrawFrm.cpp
- // Release Version: $ ODF 3 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFDraw.hpp"
-
- #ifndef DRAWFRM_H
- #include "DrawFrm.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWVIEW_H
- #include "DrawView.h"
- #endif
-
- #ifndef CLIPCMDS_H
- #include "ClipCmds.h"
- #endif
-
- #ifndef DRAWSEL_H
- #include "DrawSel.h"
- #endif
-
- #ifndef INSRTCMD_H
- #include "InsrtCmd.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef DRAWPRXY_H
- #include "DrawPrxy.h"
- #endif
-
- #ifndef SHPTRAKR_H
- #include "ShpTrakr.h"
- #endif
-
- #ifndef DRAWCMDS_H
- #include "DrawCmds.h"
- #endif
-
- #ifndef DRAWCLIP_H
- #include "DrawClip.h"
- #endif
-
- #ifndef UTILS_H
- #include "Utils.h"
- #endif
-
- #ifndef DRWDDCMD_H
- #include "DrwDDCmd.h"
- #endif
-
- #ifndef RULER_H
- #include "Ruler.h"
- #endif
-
- #ifndef DRAWCONT_H
- #include "DrawCont.h"
- #endif
-
- #ifndef PRINTHDL_H
- #include "PrintHdl.h"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWSCROLR_H
- #include "FWScrolr.h"
- #endif
-
- #ifndef FWSCLBAR_H
- #include "FWSclBar.h"
- #endif
-
- #ifndef FWGROWBX_H
- #include "FWGrowBx.h"
- #endif
-
- #ifndef FWPRHDLR_H
- #include "FWPrHdlr.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWMENU_H
- #include "FWMenu.h"
- #endif
-
- #ifndef FWRGNSHP_H
- #include "FWRgnShp.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWCURSOR_H
- #include "FWCursor.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- #ifndef FWBMPSHP_H
- #include "FWBmpShp.h"
- #endif
-
- #ifndef FWFILEOP_H
- #include "FWFileOp.h"
- #endif
-
- #ifndef FWEMBUTL_H
- #include "FWEmbUtl.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfdrawframes
- #endif
-
- FW_DEFINE_AUTO(CDrawFrame)
- FW_DEFINE_CLASS_M3(CDrawFrame, FW_CEmbeddingFrame, FW_MDraggableFrame, FW_MDroppableFrame)
-
- //========================================================================================
- // CDrawFrame
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::CDrawFrame
- //----------------------------------------------------------------------------------------
-
- CDrawFrame::CDrawFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- CDrawPart* drawPart) :
- FW_CEmbeddingFrame(ev, odFrame, presentation, drawPart),
- FW_MDraggableFrame(ev, this),
- FW_MDroppableFrame(ev, this),
- fDrawPart(drawPart),
- fSelection((CDrawSelection*)GetPresentation(ev)->GetSelection(ev)),
- fHorzRuler(NULL),
- fVertRuler(NULL),
- fGridShown(TRUE),
- fZoomFactor(FW_kFixedPos1)
- {
- fIsPrintingFrame = presentation == drawPart->GetPrintPresentation();
- fRulersShown = !fIsPrintingFrame;
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::~CDrawFrame
- //----------------------------------------------------------------------------------------
-
- CDrawFrame::~CDrawFrame()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Handled CDrawFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- FW_UNUSED(isRoot);
- // ----- Edit Menu -----
- if (hasMenuFocus)
- {
- FW_Boolean canPaste = HasPropertyOnClipboard(ev, kODPropContents, NULL); // we don't care about the type
- menuBar->EnableCommand(ev, kODCommandPaste, canPaste);
- menuBar->EnableCommand(ev, kODCommandPasteAs, canPaste);
-
- menuBar->EnableCommand(ev, cDuplicate, !GetPart(ev)->IsReadOnly(ev) && !fSelection->IsEmpty(ev));
-
- menuBar->EnableAndToggleCommand(ev, cGraphicsGrid, TRUE, fGridShown);
- menuBar->EnableAndToggleCommand(ev, cRulers, TRUE, fRulersShown);
-
- ODTypeToken defaultViewType = GetPresentation(ev)->GetDefaultEmbeddedFrameViewType(ev);
- menuBar->EnableAndCheckCommand(ev, cAsFrame, TRUE, defaultViewType == FW_CPart::fgViewAsFrameToken);
- menuBar->EnableAndCheckCommand(ev, cAsLargeIcon, TRUE, defaultViewType == FW_CPart::fgViewAsLargeIconToken);
- menuBar->EnableAndCheckCommand(ev, cAsSmallIcon, TRUE, defaultViewType == FW_CPart::fgViewAsSmallIconToken);
- menuBar->EnableAndCheckCommand(ev, cAsThumbnail, TRUE, defaultViewType == FW_CPart::fgViewAsThumbnailToken);
-
- menuBar->EnableAndCheckCommand(ev, cZoom50, TRUE, fZoomFactor == FW_DoubleToFixed(.5));
- menuBar->EnableAndCheckCommand(ev, cZoom100, TRUE, fZoomFactor == FW_kFixedPos1);
- menuBar->EnableAndCheckCommand(ev, cZoom200, TRUE, fZoomFactor == FW_IntToFixed(2));
-
- // for the menu we ignore the vPages value. It will be the same at least in this version.
- unsigned char hPages, vPages;
- fDrawPart->GetDocumentDimensions(ev, hPages, vPages);
- menuBar->EnableAndCheckCommand(ev, cPages1x1, TRUE, hPages == 1);
- menuBar->EnableAndCheckCommand(ev, cPages2x2, TRUE, hPages == 2);
- menuBar->EnableAndCheckCommand(ev, cPages3x3, TRUE, hPages == 3);
- }
-
- return FW_kNotHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::AttachSourceFrame
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::AttachSourceFrame(Environment* ev, FW_CFrame* sourceFrame)
- {
- // call inherited first
- FW_CEmbeddingFrame::AttachSourceFrame(ev, sourceFrame);
-
- // synchronize other non-content settings with the source frame
- CDrawFrame *frame = FW_DYNAMIC_CAST(CDrawFrame, sourceFrame);
-
- // At this point, we don't have any views, so all we need to do is
- // synchronize data members
-
- if(frame)
- {
- fZoomFactor = frame->GetZoomFactor();
- fRulersShown = frame->AreRulersOn();
- fGridShown = frame->IsGraphicsGridOn();
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::ChangeDocPages
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::ChangeDocPages(Environment* ev, short pages)
- {
- FW_UNUSED(pages);
- unsigned char hOld, vOld;
- fDrawPart->GetDocumentDimensions(ev, hOld, vOld);
- if(hOld != pages || vOld != pages)
- {
- fDrawPart->SetDocumentDimensions(ev, pages, pages);
-
- FW_CPoint newSize = fDrawPart->GetPageSize();
-
- newSize.x = FW_MultipliedByInt(newSize.x, pages);
- newSize.y = FW_MultipliedByInt(newSize.y, pages);
-
- fDrawPart->SetDrawingSize(ev, newSize);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::ChangeZoomFactor
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::ChangeZoomFactor(Environment* ev, FW_Fixed zoomFactor)
- {
- if(!IsPrintingFrame())
- {
- fHorzRuler->ZoomFactorChanged(ev, zoomFactor);
- fVertRuler->ZoomFactorChanged(ev, zoomFactor);
- }
-
- fZoomFactor = zoomFactor;
-
- AdjustContentViewSize(ev, FW_kDontRedraw);
-
- if(!IsPrintingFrame())
- {
- FW_ASSERT(GetScroller(ev));
- GetScroller(ev)->ScaleBy(ev, FW_CPoint(zoomFactor, zoomFactor)); // Will invalidate
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoMenu
- //----------------------------------------------------------------------------------------
-
- FW_Handled CDrawFrame::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Handled handled = FW_kHandled;
-
- ODCommandID commandID = theMenuEvent.GetCommandID(ev);
- switch (commandID)
- {
- case cDuplicate:
- {
- CDuplicateCommand* cmd = FW_NEW(CDuplicateCommand, (ev, this));
- cmd->Execute(ev);
- }
- break;
-
- case cGraphicsGrid:
- fGridShown = !fGridShown;
- GetContentView(ev)->Invalidate(ev);
- break;
-
- case cRulers:
- fRulersShown = !fRulersShown;
- ToggleRulers(ev, fRulersShown, FW_kInvalidate);
- break;
-
- case cZoom50:
- if (fZoomFactor != FW_DoubleToFixed(0.5))
- ChangeZoomFactor(ev, FW_DoubleToFixed(0.5));
- break;
- case cZoom100:
- if (fZoomFactor != FW_kFixedPos1)
- ChangeZoomFactor(ev, FW_kFixedPos1);
- break;
- case cZoom200:
- if (fZoomFactor != FW_IntToFixed(2))
- ChangeZoomFactor(ev, FW_IntToFixed(2));
- break;
-
- case cPages1x1:
- ChangeDocPages(ev, 1);
- break;
-
- case cPages2x2:
- ChangeDocPages(ev, 2);
- break;
-
- case cPages3x3:
- ChangeDocPages(ev, 3);
- break;
-
- case cAsFrame:
- GetPresentation(ev)->SetDefaultEmbeddedFrameViewType(ev, FW_CPart::fgViewAsFrameToken);
- break;
- case cAsLargeIcon:
- GetPresentation(ev)->SetDefaultEmbeddedFrameViewType(ev, FW_CPart::fgViewAsLargeIconToken);
- break;
- case cAsSmallIcon:
- GetPresentation(ev)->SetDefaultEmbeddedFrameViewType(ev, FW_CPart::fgViewAsSmallIconToken);
- break;
- case cAsThumbnail:
- GetPresentation(ev)->SetDefaultEmbeddedFrameViewType(ev, FW_CPart::fgViewAsThumbnailToken);
- break;
-
- default:
- handled = FW_kNotHandled;
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewClipboardCommand
- //----------------------------------------------------------------------------------------
-
- FW_CClipboardCommand* CDrawFrame::NewClipboardCommand(Environment* ev, ODCommandID commandID)
- {
- return FW_NEW(CDrawClipboardCommand, (ev, commandID, fDrawPart, this, fSelection, FW_kCanUndo));
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewInsertCommand
- //----------------------------------------------------------------------------------------
-
- FW_CInsertCommand* CDrawFrame::NewInsertCommand(Environment* ev, const FW_PFileSpecification& fileSpec)
- {
- return FW_NEW(CDrawInsertCommand, (ev, this, fileSpec, fSelection, FW_kCanUndo));
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::CanAcceptDrop
- //----------------------------------------------------------------------------------------
- // As an embedding frame I can accept anything
-
- ODDragResult CDrawFrame::CanAcceptDrop(Environment *ev, ODDragItemIterator* dragInfo)
- {
- FW_UNUSED(ev);
- FW_UNUSED(dragInfo);
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoActivateEvent
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::DoActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent)
- {
- FW_UNUSED(theActivateEvent);
-
- if (HasSelectionFocus(ev))
- fSelection->InvalidateSelectionHandles(ev, this);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::AdjustZoomedWindowSize
- //----------------------------------------------------------------------------------------
- // Called when the window is zoomed
-
- void CDrawFrame::AdjustZoomedWindowSize(Environment* ev, FW_CPoint& proposedSize)
- {
- FW_UNUSED(ev);
- proposedSize = fDrawPart->GetDrawingSize();
- proposedSize.x *= fZoomFactor;
- proposedSize.y *= fZoomFactor;
-
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
-
- if (fRulersShown)
- {
- sbSize.x += kRulerWidth;
- sbSize.y += kRulerWidth;
- }
-
- proposedSize.x += sbSize.x + FW_IntToFixed(3); // I want to leave a little space around
- proposedSize.y += sbSize.y + FW_IntToFixed(3);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::AdjustWindowGrowLimits
- //----------------------------------------------------------------------------------------
- // Called when the window is resized
-
- void CDrawFrame::AdjustWindowGrowLimits(Environment* ev, FW_CPoint& minSize, FW_CPoint& maxSize)
- {
- FW_UNUSED(ev);
- FW_UNUSED(maxSize);
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
-
- if (fRulersShown)
- {
- sbSize.x += kRulerWidth;
- sbSize.y += kRulerWidth;
- }
-
- minSize.x = FW_IntToFixed(72) + sbSize.x;
- minSize.y = FW_IntToFixed(72) + sbSize.y;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::PostCreateViewFromStream
- //----------------------------------------------------------------------------------------
- // PostCreateViewFromStream is called after subviews are created from resources.
- // Add code which cannot be handled by current resource types.
-
- void CDrawFrame::PostCreateViewFromStream(Environment* ev)
- {
- if(!IsPrintingFrame())
- {
- fHorzRuler = (CRuler*) FindViewByID(ev, kHorzRulerID);
- fVertRuler = (CRuler*) FindViewByID(ev, kVertRulerID);
-
- fHorzRuler->ZoomFactorChanged(ev, fZoomFactor);
- fVertRuler->ZoomFactorChanged(ev, fZoomFactor);
-
- if (!fRulersShown)
- ToggleRulers(ev, FALSE, FW_kDontRedraw);
- }
-
- AdjustContentViewSize(ev, FW_kDontRedraw);
-
- // WARNING: Make sure that classes created from resources won't be dead-stripped
- FW_DO_NOT_DEAD_STRIP(FW_CGrowBox);
- FW_DO_NOT_DEAD_STRIP(FW_CScrollBarScroller);
- FW_DO_NOT_DEAD_STRIP(FW_CScrollBar);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::GetContentRect
- //----------------------------------------------------------------------------------------
-
- FW_CRect CDrawFrame::GetContentRect(Environment* ev) const
- {
- FW_CRect contentRect = GetBounds(ev);
-
- if (fRulersShown)
- {
- // Make space for rulers
- contentRect.top += kRulerWidth;
- contentRect.left += kRulerWidth;
- }
-
- if (IsRoot(ev) && ! fIsPrintingFrame)
- {
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
-
- contentRect.bottom -= sbSize.y;
- contentRect.right -= sbSize.x;
- }
-
- return contentRect;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::AdjustContentViewSize
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::AdjustContentViewSize(Environment* ev, FW_ERedrawVerb redraw)
- {
- FW_CRect contentRect = GetContentRect(ev);
-
- FW_CPoint drawingSize = fDrawPart->GetDrawingSize();
-
- // ----- I need to take into account the zoom factor -----
- drawingSize.x *= fZoomFactor;
- drawingSize.y *= fZoomFactor;
-
- FW_CPoint drawViewSize(FW_Minimum(drawingSize.x, contentRect.Width()),
- FW_Minimum(drawingSize.y, contentRect.Height()));
-
- FW_CPoint currentSize = GetContentView(ev)->GetSize(ev);
- if (currentSize != drawViewSize)
- {
- if(!IsPrintingFrame())
- {
- fHorzRuler->SetSize(ev, FW_CPoint(drawViewSize.x, kRulerWidth), redraw);
- fVertRuler->SetSize(ev, FW_CPoint(kRulerWidth, drawViewSize.y), redraw);
- }
-
- GetContentView(ev)->SetSize(ev, drawViewSize, redraw);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewDragCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDragCommand* CDrawFrame::NewDragCommand(Environment *ev, FW_CFrame* theFrame, const FW_CMouseEvent& theMouseEvent)
- {
- FW_UNUSED(theMouseEvent);
- return FW_NEW(CDrawDragCommand, (ev, fDrawPart, theFrame,
- fSelection,
- FW_kCanUndo));
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewDropCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDropCommand* CDrawFrame::NewDropCommand(Environment *ev,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* facet,
- const FW_CPoint& dropPoint)
- {
- return FW_NEW(CDrawDropCommand, (ev, fDrawPart, frame,
- dropInfo, facet, dropPoint,
- FW_kCanUndo));
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::InvalidateShadowRect
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::InvalidateShadowRect(Environment *ev)
- {
- FW_CRect bounds = GetContentView(ev)->GetBounds(ev);
-
- // ----- I always remove the rulers so I am sure I will invalidate enough -----
- bounds.left -= kRulerWidth;
- bounds.top -= kRulerWidth;
-
- bounds.Inset(FW_kFixedNeg1, FW_kFixedNeg1);
-
- Invalidate(ev, bounds);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::ToggleRulers
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::ToggleRulers(Environment *ev, FW_Boolean visible, FW_ERedrawVerb redraw)
- {
- FW_ASSERT(fHorzRuler != NULL && fVertRuler != NULL);
- fHorzRuler->SetVisible(ev, visible);
- fVertRuler->SetVisible(ev, visible);
-
- FW_CRect frameRect = GetContentRect(ev);
-
- FW_CSuperView* contentView = GetContentView(ev);
-
- // I need to invalidate one more pixel for the black border
- if (redraw == FW_kInvalidate)
- InvalidateShadowRect(ev);
-
- GetContentView(ev)->SetLocation(ev, frameRect.TopLeft(), redraw);
-
- if (redraw == FW_kInvalidate)
- InvalidateShadowRect(ev);
-
- AdjustContentViewSize(ev, redraw);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_CViewContext vc(ev, this, odFacet, invalidShape);
-
- FW_CSuperView* contentView = GetContentView(ev);
- FW_CRect contentRect = GetContentRect(ev);
- FW_CRect contentBounds = contentView->GetBounds(ev);
-
- // The only thing to draw is the top left corner box
- if (fRulersShown)
- {
- FW_CRect box(FW_kFixedNeg1, FW_kFixedNeg1, kRulerWidth, kRulerWidth);
- FW_CRectShape::RenderRect(vc, box, FW_kFill, FW_kWhiteEraseInk);
- FW_CRectShape::RenderRect(vc, box, FW_kFrame, FW_kNormalInk, FW_CStyle(FW_kFixed0));
-
- contentRect.left -= kRulerWidth;
- contentRect.top -= kRulerWidth;
-
- contentBounds.left -= kRulerWidth;
- contentBounds.top -= kRulerWidth;
- }
-
- if(odFacet->GetCanvas(ev)->IsDynamic(ev))
- {
- FW_CAcquiredODShape shape1 = ::FW_NewODShape(ev, contentRect);
- FW_CAcquiredODShape shape2 = ::FW_NewODShape(ev, contentBounds);
- shape1->Subtract(ev, shape2);
- if (!shape1->IsEmpty(ev))
- {
- FW_CRegionShape::RenderRegion(vc, shape1, FW_kFill, FW_kRGBLightGray);
-
- contentBounds.Inset(FW_kFixedNeg1, FW_kFixedNeg1);
- FW_CRectShape::RenderRect(vc, contentBounds, FW_kFrame);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewPrintHandler
- //----------------------------------------------------------------------------------------
-
- FW_CPrintHandler* CDrawFrame::NewPrintHandler(Environment* ev)
- {
- if (GetPresentation(ev) == fDrawPart->GetMainPresentation())
- return new CDrawPrintHandler(ev, this, fDrawPart->GetDrawContent(), fDrawPart->GetPrintPresentation());
- else
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::GetPrintResolution
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::GetPrintResolution(Environment* ev, unsigned long& res)
- {
- FW_UNUSED(ev);
-
- res = 288;
- }
-
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::FacetAdded
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::FacetAdded(Environment* ev, ODFacet* facet, unsigned short facetCount)
- {
- FW_CEmbeddingFrame::FacetAdded(ev, facet, facetCount); // Call inherited
-
- // Perform "DoPostCreate"-type initialization here.
- fDrawPart->DoPostCreate(ev);
-
- if(facetCount == 1)
- {
- // do this for the frame's first facet
- unsigned char hPages, vPages;
- fDrawPart->GetDocumentDimensions(ev, hPages, vPages);
-
- FW_CPoint newSize = fDrawPart->GetPageSize();
- newSize.x = FW_MultipliedByInt(newSize.x, hPages);
- newSize.y = FW_MultipliedByInt(newSize.y, vPages);
-
- fDrawPart->SetDrawingSize(ev, newSize);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::ExternalizeFrame
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::ExternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
- {
- FW_CEmbeddingFrame::ExternalizeFrame(ev, storageUnitView);
-
- FW_PStorageUnitSink suSink(ev, storageUnitView);
- FW_CWritableStream stream(suSink);
-
- stream << fGridShown;
- stream << fRulersShown;
- stream << fZoomFactor;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::InternalizeFrame
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::InternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
- {
- FW_CEmbeddingFrame::InternalizeFrame(ev, storageUnitView);
-
- FW_PStorageUnitSink suSink(ev, storageUnitView);
- FW_PBufferedSink sink(ev, suSink);
- FW_CReadableStream stream(sink);
-
- stream >> fGridShown;
- stream >> fRulersShown;
- stream >> fZoomFactor;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::FocusStateChanged
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::FocusStateChanged(Environment *ev, ODTypeToken focus, FW_Boolean newState, ODFrame* newOwner)
- {
- FW_CEmbeddingFrame::FocusStateChanged(ev, focus, newState, newOwner);
-
- if (focus == FW_CPart::fgSelectionFocusToken)
- {
- // If I am losing the selection focus for a frame other than one of mine then
- // set back the current tool to the selection tool
- if (!this->IsSiblingFrameOf(ev, newOwner))
- fDrawPart->SetTool(ev, kSelectTool);
-
- FW_CWindow* wind = GetWindow(ev);
- if (wind && wind->IsActive(ev))
- fSelection->InvalidateSelectionHandles(ev, this);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::IsInLinkDestination
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CDrawFrame::IsInLinkDestination(Environment* ev)
- {
- return (this->GetODFrame(ev)->GetLinkStatus(ev) == kODInLinkDestination);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::EmbeddedFrameRequested
- //----------------------------------------------------------------------------------------
-
- FW_MProxy* CDrawFrame::EmbeddedFrameRequested(Environment *ev,
- FW_MProxy* baseProxy,
- ODFrame* baseFrame,
- ODShape* frameShape,
- ODPart* embeddedPart,
- ODTypeToken viewType,
- ODTypeToken presentation,
- ODID frameGroupID,
- FW_Boolean isOverlaid,
- FW_Boolean isSubFrame)
- {
- FW_UNUSED(baseFrame);
- FW_UNUSED(frameShape);
- FW_CPresentation* myPresentation = GetPresentation(ev);
-
- CProxyShape* baseProxyShape = (CProxyShape*)baseProxy;
- FW_CRect embeddedFrameBounds = baseProxyShape->GetFrameRect(ev);
-
- embeddedFrameBounds.Offset(embeddedFrameBounds.Width(), FW_kFixed0);
-
- CProxyShape* proxy = FW_NEW(CProxyShape, (ev, embeddedFrameBounds, fDrawPart));
-
- FW_CRect tempRect(embeddedFrameBounds);
- tempRect.Place(FW_kFixed0, FW_kFixed0);
- FW_CAcquiredODShape aqFrameShape = ::FW_NewODShape(ev, tempRect);
-
- FW_TRY
- {
- proxy->EmbedPart(ev,
- myPresentation,
- embeddedPart,
- kODFrameObject,
- aqFrameShape,
- viewType,
- presentation,
- frameGroupID,
- isOverlaid,
- isSubFrame);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING ()
- {
- proxy->Release();
- FW_THROW_SAME ();
- }
- FW_CATCH_END
-
- // ----- Now I can add it to my data
- fDrawPart->AddShapeToPart(ev, proxy);
-
- // AddShapeToPart acquired proxy. Since this function is actually returning
- // an FW_MProxy, which is currently not refcounted, the caller (which is
- // happens to be a framework method) can't be counted on to release, so we
- // have to do so for it.
-
- proxy->Release();
-
- // ----- Clip the facets -----
- CDrawFacetClipper facetClipper(fDrawPart);
- FW_CAcquiredODShape limitShape = ::FW_NewODShape(ev, embeddedFrameBounds);
- facetClipper.Clip(ev, myPresentation, limitShape);
-
- return proxy;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::AdjustCursor
- //----------------------------------------------------------------------------------------
- // Rewrote AdjustCursor so we test for the case where the proxy is grouped
-
- FW_Handled CDrawFrame::AdjustCursor(Environment *ev, ODFacet* facet, const FW_CPoint& theMousePoint, ODEventInfo* eventInfo)
- {
- FW_UNUSED(eventInfo);
-
- FW_Handled handled = FW_kNotHandled;
-
- ODFacet* embeddedFacet = GetFacetWithActiveBorderUnderMouse(ev, facet, theMousePoint);
- if (embeddedFacet != NULL)
- {
- CProxyShape* proxy = FW_DYNAMIC_CAST(CProxyShape, fDrawPart->GetProxy(ev, embeddedFacet->GetFrame(ev)));
- if (proxy->IsGrouped())
- FW_gArrowCursor.Select();
- else
- FW_gOpenHandCursor.Select();
-
- handled = FW_kHandled;
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoMouseDownInEmbeddedFrameBorder
- //----------------------------------------------------------------------------------------
- // Start Dragging an embedded frame using the active border
-
- FW_Handled CDrawFrame::DoMouseDownInEmbeddedFrameBorder(Environment *ev, const FW_CBorderMouseEvent& theBorderMouseEvent)
- {
- ActivateFrame(ev, theBorderMouseEvent.GetFacet(ev));
-
- fDrawPart->SetTool(ev, kSelectTool);
-
- CProxyShape* proxy = FW_DYNAMIC_CAST(CProxyShape, fDrawPart->GetProxy(ev, theBorderMouseEvent.GetEmbeddedFacet(ev)->GetFrame(ev)));
- if (!proxy->IsGrouped())
- {
- FW_gClosedHandCursor.Select();
- Drag(ev, theBorderMouseEvent);
- }
-
- return FW_kHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoMouseDownInEmbeddedFrame
- //----------------------------------------------------------------------------------------
- // Test for double click in a embeddedFrame
-
- FW_Handled CDrawFrame::DoMouseDownInEmbeddedFrame(Environment* ev,
- const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent)
- {
- FW_Handled handled = FW_kNotHandled;
-
- if (theEmbeddedMouseEvent.GetNumberOfClicks(ev) > 1)
- {
- ((FW_CEmbeddingFrame*)GetFrame(ev))->OpenSelection(ev);
- handled = FW_kHandled;
- }
-
- return handled;
- }
-
-